package ru.tulupov.toyfactory.pattern.impl;

import java.util.Observable;
import java.util.Observer;

import ru.tulupov.toyfactory.model.Playable;
import ru.tulupov.toyfactory.model.ThreadManager;
import ru.tulupov.toyfactory.pattern.Producer;
import ru.tulupov.toyfactory.pattern.Storage;

public abstract class AbstractProducer extends Producer<Playable> implements
		Observer {

	public AbstractProducer(Storage<Playable> storage) {
		super(storage);
		ThreadManager.getInstance().addObserver(this);
	}

	@Override
	public void update(Observable observable, Object obj) {

		interrupt();
	}

	@Override
	public void interrupt() {

		ThreadManager.getInstance().interruptAll(this);

		super.interrupt();
	}
}
